home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2002 January / maximum-cd-2002-01.iso / Files / Mechwarrior 4 Mapping / MW4Editor.exe / content / ABLScripts / GenericScripts / Generic_ArmedConvoy.abl < prev    next >
Encoding:
Text File  |  2001-07-16  |  5.2 KB  |  172 lines

  1.  
  2. //------------------------------------------------------------------
  3. // NOTE: The fsm name below MUST be changed in order for the
  4. // script to be considered a unique entity!
  5.  
  6. fsm Generic_ArmedConvoy : integer;
  7.  
  8.  
  9. //------------------------------------------------------------------
  10.  
  11. // Generic_ArmedConvoy:
  12. //   Follows a path but breaks off to attack enemies.
  13.  
  14. //------------------------------------------------------------------
  15.  
  16.  
  17.  
  18. //------------------------------------------------------------------
  19. //     Constants
  20. //------------------------------------------------------------------
  21.  
  22.     const
  23.         #include_ <content\ABLScripts\mwconst.abi>
  24.  
  25. //------------------------------------------------------------------
  26. //     Types
  27. //------------------------------------------------------------------
  28.  
  29.     type
  30.         #include_ <content\ABLScripts\mwtype.abi>
  31.     
  32.  
  33. //------------------------------------------------------------------
  34. //     Variables
  35. //------------------------------------------------------------------
  36.  
  37.     var
  38.         static integer            attackRange;        // At what range do I start attacking?
  39.         static integer            withdrawRange;        // At what range do I withdraw from combat?
  40.         static integer            groupNumber;        // What's my group -- i.e. I will use GroupObjectID(groupNumber) to identify my group
  41.         static integer            speed;                // The speed at which I move along the path
  42.         static integer            formationType;        // What kind of formation am I in?
  43.         static integer            formationDensity;    // How densely are we packed?
  44.         static integer            path;                // My path
  45.         static integer            moveType;            // How I move along the path
  46.  
  47.         static integer            piloting;            // Piloting skill
  48.         static integer            gunnery;            // Gunnery skill/chance to hit
  49.         static real                minDelay;            // Minimum amount of time I will wait between shots once a weapon is reloaded
  50.         static real                maxDelay;            // Maximum amount of time I will wait between shots once a weapon is reloaded
  51.         static integer             eliteLevel;            // Elite level.  This helps determine tactics, defensive manuevers, opportunity fire
  52.                                                     // and other things.  It indicates a general level of combat experience.
  53.         static integer            attackThrottle;        // My attack throttle
  54.  
  55.          static integer            isShotRadius;        // How far away from me will I detect an enemy shot?
  56.         static integer            findTypes;            // What kind of enemies to look for
  57.  
  58.         static integer             attackSound;        // The attack sound I play when I first attack
  59.         static integer             deathSound;            // The sound I play when I die
  60.         
  61.         static integer            mood;                // My default mood.
  62.  
  63.         static integer            takeOffDistance;    // My take-off distance if I'm an airplane (ignored if not an airplane)
  64.  
  65. //------------------------------------------------------------------
  66. //     Init: my initialization function
  67. //------------------------------------------------------------------
  68.  
  69. function Init;
  70.     code
  71.         // script-specific variables
  72.         attackRange        = 500;
  73.         withdrawRange    = attackRange * 3 / 2;
  74.         groupNumber        = 0;
  75.         path            = -1;
  76.         moveType        = move_nocycle;
  77.         speed            = 50;
  78.         formationType    = 1;
  79.         formationDensity= formtype_sparse;
  80.         takeOffDistance    = 150;
  81.  
  82.         // driver settings
  83.         piloting        = 50;
  84.         gunnery            = 30;
  85.         minDelay        = 1.5;
  86.         maxDelay        = 3.0;
  87.         eliteLevel        = 30;
  88.         attackThrottle    = 80;
  89.         isShotRadius    = 120;
  90.         attackSound        = -1; // no sound
  91.         deathSound        = -1; // no sound
  92.         mood            = NEUTRAL_START;
  93.         findTypes        = FT_DEFAULT;
  94.  
  95. endfunction;
  96.  
  97. //------------------------------------------------------------------
  98. //    StartState: my initial state
  99. //------------------------------------------------------------------
  100.  
  101. state StartState;
  102.  
  103.     code
  104.         SetFiringDelay            (ME,minDelay,maxDelay);
  105.         SetIgnoreFriendlyFire    (ME,true);
  106.         SetIsShotRadius            (ME,isShotRadius);
  107.         SetEntropyMood            (ME,mood);
  108.         SetCurMood                (ME,mood);
  109.         SetSkillLevel            (ME,piloting,gunnery,eliteLevel);
  110.         SetAttackThrottle        (ME,attackThrottle);
  111.  
  112.         if (orderTakeOff(takeOffDistance) == true) then
  113.             trans FollowPathState;
  114.         endif;
  115.  
  116. endstate;
  117.  
  118. //------------------------------------------------------------------
  119. //    FollowPathState: follow our path, but keep an eye out for enemies
  120. //------------------------------------------------------------------
  121.  
  122. state FollowPathState;
  123.     code
  124.         if (FindEnemy(attackRange,findTypes)) then
  125.             trans AttackState;
  126.         endif;
  127.  
  128.         if (path <> -1) then
  129.             OrderFormationMove((groupobjectid(groupNumber)),path,speed,moveType,formationType,formationDensity,false);
  130.         else
  131.             OrderMoveLookOut;
  132.         endif;
  133. endstate;
  134.  
  135. //------------------------------------------------------------------
  136. //    AttackState: attack my target
  137. //------------------------------------------------------------------
  138.  
  139. state AttackState;
  140.     code
  141.         if (LeaveAttackState(withdrawRange)) then
  142.             OrderStopAttacking;
  143.             SetTarget(ME,NO_UNIT);
  144.             trans FollowPathState;
  145.         endif;
  146.  
  147.         if (attackSound <> -1) then    
  148.             PlaySoundOnce(attackSound);
  149.         endif;
  150.  
  151.         OrderAttack(true);
  152.  
  153. endstate;
  154.  
  155. //------------------------------------------------------------------
  156. //    DeadState: OK, I kicked the bucket.
  157. //------------------------------------------------------------------
  158.  
  159. state DeadState;
  160.     code
  161.         if (deathSound <> -1) then    
  162.             PlaySoundOnce(deathSound);
  163.         endif;        
  164.  
  165.         orderDie;
  166.  
  167. endstate;
  168.  
  169.  
  170. endfsm.
  171.  
  172.